import React from 'react'
import { success, error, info, Link, Toast, Input, Button, Checkbox } from '../ui-components'
import style from './style'
import { connect } from 'react-redux'
import util from '../util'
import rule from '../libs'

class SetPassword extends React.Component {

  state = {
    password: '',
    repassword: ''
  }

	static contextTypes = {
		router: React.PropTypes.object
	}

  handleSubmit() {
    const { password, repassword } = this.state
    if (util.isNull(password) || util.isNull(repassword)) return
    if (password !== repassword) return error('两次输入密码不一致')

    this.props.setPassword(password, () => {
      this.context.router.push('/login')
      success('设置密码成功, 请登录!')
    })
  }

	render() {
    return (
      <div>
        <div className={style.form}>
          <h2 className={style.title}>设置您的新密码</h2>
          <div className={style.input}>
            <input type="password" placeholder={rule.password.msg}/>
          </div>
          <button className={style.button}>确定</button>
        </div>
      </div>
    )
	}
}

export default SetPassword
